(setq package-archives '(("gnu"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
                         ("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
(package-initialize)

(defvar *lutts-packages* '(gnu-elpa-keyring-update auto-package-update))

(defvar lutts-init-hook nil)

(defun lutts-load-package (fun &rest packages)
  (dolist (i packages)
    (add-to-list '*lutts-packages* i))
  (add-hook 'lutts-init-hook fun))


;;Auto update
(add-hook 'after-init-hook 'auto-package-update-maybe)

;; Mysettings about package
(require 'oi-mode)
(require 'change-theme-mode)

(require 'init-diminish)
(require 'init-evil)
(require 'init-company)
(require 'init-slime)
(require 'init-pyim)
(require 'init-ivy)
(require 'init-flycheck)
(require 'init-editor)
(require 'init-ui)
(require 'init-magit)

(defun lutts-run-init nil
  (package-refresh-contents t)
  (dolist (pkg *lutts-packages*)
    (when (not (package-installed-p pkg))
      (package-install pkg)))

  (run-hooks 'lutts-init-hook))

(lutts-run-init)

(provide 'init-packages)
